package com.company.utils;

import com.company.entity.Order;
import com.company.entity.ServicePoint;
import com.company.entity.Visit;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 寄件
 */
public class MailUtil {
    public void inputInfo(){
        Scanner input = new Scanner(System.in);
        Order order = null;
        System.out.print("请选择寄件方式: 1.上门取件 2.服务点自寄 ");
        switch (input.nextInt()){
            case 1:
                order = new Visit();
                order.setPickupType("上门取件");
                break;
            case 2:
                order = new ServicePoint();
                order.setPickupType("服务点自寄");
                break;
        }
        System.out.print("请输入寄件人信息: ");
        order.setSenderInfo(input.next());
        System.out.print("请输入收件人信息: ");
        order.setRecipientInfo(input.next());
        System.out.print("请选择物品类型: 1.日用品 2.食品 3.文件 4.衣物 5.数码产品 6.其他  ");
        switch (input.nextInt()){
            case 1:
                order.setItemType("日用品");
                break;
            case 2:
                order.setItemType("食品");
                break;
            case 3:
                order.setItemType("文件");
                break;
            case 4:
                order.setItemType("衣物");
                break;
            case 5:
                order.setItemType("数码产品");
                break;
            case 6:
                order.setItemType("其他");
                break;
        }
        System.out.print("请选择取件时间: 1.9:00~13:00 2.14:00~19:00  ");
        switch (input.nextInt()){
            case 1:
                order.setTime("9:00~13:00");
                break;
            case 2:
                order.setTime("14:00~19:00");
                break;
        }
        System.out.print("请输入物品预估重量(kg): ");
        order.setWeight(input.nextInt());
        System.out.print("是否保价(y/n): ");
        if (input.next().equals("y")){
            order.setSupportValue(true);
            System.out.print("请输入寄件物品估价(单位：元，按0.5%支付保价费): ");
            order.setPrice(input.nextInt());
        }else if(input.next().equals("n")){
            order.setSupportValue(false);
        }
        order.showInfo();
        //将信息存入集合
        MyOrderUtil.orders.add(order);
    }
}
